import json 

new_data = []

with open('Cybersecurity-ShareGPT-Chinese.json', 'r', encoding='utf-8') as f:
    data = json.load(f)
    
for item in data:
    # new_data.append(
    #     {
    #         'instruction': item["conversations"][0]['value'],
    #         'input': item["conversations"][1]['value'],
    #         'output': item["conversations"][2]['value']
    #     }
    # )
    new_data.append(
        {
            "messages":         
                    [
                {
                    "role": "user",
                    "content": item["conversations"][1]['value']
                },
                {
                    "role": "assistant",
                    "content": item["conversations"][2]['value']
                }
            ]
        }

    )


# with open('seed_generation-14k.json', 'r', encoding='utf-8') as f:
#     data = json.load(f)

# for item in data:
#     new_data.append(item)

with open('Cybersecurity-Chinese-V2.json', 'w', encoding='utf-8') as f:
    json.dump(new_data, f, ensure_ascii=False, indent=4)